﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace peonwar
{
    public class InfoDisplay
    {
        public static bool Enabled;
        int FrameRate;
        public int FrameCounter;
        SpriteFont Font;
        TimeSpan ElapsedTime;

        public InfoDisplay(SpriteFont font)
        {
            this.FrameRate = 0;
            this.FrameCounter = 0;
            this.Font = font;
            ElapsedTime = TimeSpan.Zero;
        }

        public void Update(GameTime gameTime)
        {
            ElapsedTime += gameTime.ElapsedGameTime;
            if (ElapsedTime > TimeSpan.FromSeconds(1))
            {
                ElapsedTime -= TimeSpan.FromSeconds(1);
                FrameRate = FrameCounter;
                FrameCounter = 0;
            }
        }

        public void Draw(SpriteBatch spriteBatch, int ticks, int highticks, ParticleComponent p)
        {
            if (Enabled)
            {
                Color c = Game.CurrentMap.Chatcolor;
                spriteBatch.DrawString(Font, "FPS      : " + FrameRate, new Vector2(750, 40), c);
                spriteBatch.DrawString(Font, "Ticks    : " + ticks, new Vector2(750, 60), c);
                spriteBatch.DrawString(Font, "Frame   : " + highticks, new Vector2(750, 80), c);
                spriteBatch.DrawString(Font, "Sync   : " + GameServer.SyncOperation, new Vector2(750, 100), c);
                spriteBatch.DrawString(Font, "P1 Units : " + Game.p1_player.PeonList.Count(), new Vector2(750, 120), c);

                spriteBatch.DrawString(Font, "Particles Count : " + ParticleComponent.ParticleCount, new Vector2(900, 40), c);
                spriteBatch.DrawString(Font, "Advert Count    : " + User.AdvertList.Count(), new Vector2(900, 60), c);
                spriteBatch.DrawString(Font, "Effect Count      : " + User.EffectList.Count(), new Vector2(900, 80), c);
                spriteBatch.DrawString(Font, "Achiv  Count      : " + User.AchievertList.Count(), new Vector2(900, 100), c);
                spriteBatch.DrawString(Font, "P2 Units          : " + Game.p2_opponent.PeonList.Count(), new Vector2(900, 120), c);
            }
        }
    }
}
